def write_answer(pre=''):
    def wrapper(F):
        def internal(write):
             if write == True:
                 result = F(write)
                 with open('/path/a.txt', 'w') as f:
                    f.write(result)
             else:
                 print pre
                 F(write)
        return internal
    return wrapper
               
 
class Question(object):
    @write_answer('logging...')
    def all_answer(self, write=False):
        #下面代码部分直接忽略吧
        answer_number = self.answer_number()
        reg_img = r'http://pic3.zhimg.com/\w+\.jpg'
        if answer_number == 0:
            print "This question is no answers"
        else:
            re_br = re.compile(r'<br/?>')
            re_allmark = re.compile(r'<[^>]+>',re.S)
            all_answer_list = self.soup.find_all( 'div', 'zm-item-answer ') 
            for each in all_answer_list:
                print each.h3.get_text()  
                content = str(each.find('div', ' zm-editable-content clearfix')) 
                br2n = re.sub(re_br, '\n', content)
                for s in br2n.split('\n'):
                    print re.sub(re_allmark, '', s)